package com.itwjr.JDBC;

import java.sql.*;

public class Test {
    public static void main(String[] args) throws Exception {
        //注册驱动
        Class.forName("com.mysql.jdbc.Driver");
//获取数据库连接
        String url = "jdbc:mysql://127.0.0.1:3306/db1";
        String user = "root";
        String psw = "1234";
        Connection connection = DriverManager.getConnection(url, user, psw);
        //定义sql语句
        String sql = "UPDATE stu SET age = 90 WHERE id = 1";

        //获取执行SQL对象
        //执行SQL语句需要SQL执行对象，而这个执行对象就是Statement对象
        Statement statement = connection.createStatement();
        //执行sql语句
        statement.executeUpdate(sql);
        statement.close();
        connection.close();

    }
}
